import { createRouter, createWebHashHistory, createWebHistory, createMemoryHistory } from 'vue-router'

//1.声明router配置 一个routers是一个数组 
//routers里面的基本属性由path 和 component组成

let routes = [

    {
        path: '/',
        component: () => import('../pages/home/index.vue'),
        //具名路由
        name: '/',
        meta: {
            //meta里的属性可以随便添加
            name: '导航首页'
        },
        children: [
            {
                path: 'discover',
                component: () => import('../pages/discover/index.vue'),
                name: 'discover',
                meta: {
                    name: '发现'
                },
                //重定向
                redirect: '/discover/playlist',
                children: [
                    {
                        //子路由path里不写/
                        path: 'playlist',
                        component: () => import('../pages/discover/playList/index.vue'),
                        name: 'playlist',
                        meta: {
                            name: '歌单'
                        },
                    }
                ]


            },
            {
                //路由解耦合
                props: true,
                //动态路由
                path: 'friend/:id',
                component: () => import('../pages/friend/index.vue'),
                name: 'friend',
                meta: {
                    name: '朋友'
                },

            },
            {
                path: 'mine',
                component: () => import('../pages/mine/index.vue'),
                name: 'mine',
                meta: {
                    name: '我的'
                },
            }
        ]

    },
    {
        path: '/login',
        component: () => import('../pages/login/index.vue'),
        name: 'login',
        meta: {
            name: '登录'
        },
    }
]
//2.创建路由
const router = createRouter({
    history: createWebHashHistory('/base'),
    routes
})
//导出路由
export default router